/**
 * 
 */
package com.archives.blog.common.domain.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

import com.archives.blog.common.domain.pojo.request.ArticleAddRequest;
import com.archives.blog.common.domain.pojo.request.ArticleModifyRequest;
import com.archives.blog.common.support.BaseEntity;

/**
 * @author chh
 *
 */
@Entity
@Table(name = "blog_article")
public class Article extends BaseEntity<Long>  implements Serializable{

	public void add(ArticleAddRequest request, ArticleChannel channel){
		this.setAuthor(request.getAuthor());
		this.setContent(request.getContent());
		this.setIntro(request.getIntro());
		this.setKeywords(request.getKeywords());
		this.setLogoImg(request.getLogoImg());
		this.setTitle(request.getTitle());
		this.setCreater(request.getOperator());
		this.setModifier(request.getOperator());
		this.setGmtCreate(new Date());
		this.setGmtModifyed(new Date());

		this.setChannelId(channel.getId());
		this.setChannelName(channel.getName());
	}
	
	public void modify(ArticleModifyRequest request, ArticleChannel channel){
		this.setAuthor(request.getAuthor());
		this.setContent(request.getContent());
		this.setIntro(request.getIntro());
		this.setKeywords(request.getKeywords());
		this.setLogoImg(request.getLogoImg());
		this.setTitle(request.getTitle());
		this.setModifier(request.getOperator());
		this.setGmtModifyed(new Date());

		this.setChannelId(channel.getId());
		this.setChannelName(channel.getName());
	}
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Column(nullable = false)
	private String author;

	@Column(nullable = false)
	private String title;

	@Column(nullable = false)
	private String intro;

	@Column(nullable = false)
	private String content;

	@Column(nullable = false)
	private String logoImg;

	@Column(nullable = false)
	private String keywords;

	@Column(nullable = false)
	private Long channelId;
	
	@Column(nullable = false)
	private String channelName;
	
	/**
	 * @return the author
	 */
	public String getAuthor() {
		return author;
	}

	/**
	 * @param author the author to set
	 */
	public void setAuthor(String author) {
		this.author = author;
	}

	/**
	 * @return the title
	 */
	public String getTitle() {
		return title;
	}

	/**
	 * @param title the title to set
	 */
	public void setTitle(String title) {
		this.title = title;
	}

	/**
	 * @return the intro
	 */
	public String getIntro() {
		return intro;
	}

	/**
	 * @param intro the intro to set
	 */
	public void setIntro(String intro) {
		this.intro = intro;
	}

	/**
	 * @return the content
	 */
	public String getContent() {
		return content;
	}

	/**
	 * @param content the content to set
	 */
	public void setContent(String content) {
		this.content = content;
	}

	/**
	 * @return the logoImg
	 */
	public String getLogoImg() {
		return logoImg;
	}

	/**
	 * @param logoImg the logoImg to set
	 */
	public void setLogoImg(String logoImg) {
		this.logoImg = logoImg;
	}

	/**
	 * @return the keywords
	 */
	public String getKeywords() {
		return keywords;
	}

	/**
	 * @param keywords the keywords to set
	 */
	public void setKeywords(String keywords) {
		this.keywords = keywords;
	}

	/**
	 * @return the channelId
	 */
	public Long getChannelId() {
		return channelId;
	}

	/**
	 * @param channelId the channelId to set
	 */
	public void setChannelId(Long channelId) {
		this.channelId = channelId;
	}

	/**
	 * @return the channelName
	 */
	public String getChannelName() {
		return channelName;
	}

	/**
	 * @param channelName the channelName to set
	 */
	public void setChannelName(String channelName) {
		this.channelName = channelName;
	}
	
}
